package com.kuangstudy.io.test;

import java.sql.SQLOutput;
import java.util.*;

/**
 * ClassName: Demo2
 * date: 2021/07/16 18:59:44
 *
 * @author zlk
 */
public class Demo2 {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("332", "aaa");
        map.put("32", "aaa");
        map.put("1234", "aaa");
        map.put("4", "aaa");
        map.put("5", "aaa");
        System.out.println(map.toString());
        List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>(map.entrySet()); //转换为list
        list.sort(new Comparator<Map.Entry<String, String>>() {
            @Override
            public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
                return Integer.parseInt(o1.getKey()) - Integer.parseInt(o2.getKey());
            }
        });
        System.out.println(list);
    }
}
